﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Rubyer;
using StockUI.Model;
using StockUI.Views;
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Reflection.Metadata;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml;
using System.Xml.Linq;

namespace StockUI.ViewModels
{
    /// <summary>
    /// 今日行情数据
    /// </summary>
    public partial class HomeViewModel : ObservableObject
    {
        [ObservableProperty]
        private ObservableCollection<ZsDataModel> zsItems;

        [ObservableProperty]
        private ObservableCollection<HomeTabsItemModel> tabsItems;

        [ObservableProperty]
        private ObservableCollection<HomeTabsModel> lhbItems;
        public HomeViewModel()
        {
            ObservableCollection<ZsDataModel> list = new ObservableCollection<ZsDataModel>();
            for (int i = 0; i < 20; i++)
            {
                list.Add(new ZsDataModel { 
                    Code = $"00000{i}",
                    Url= "https://quote.eastmoney.com/zs000001.html",
                    Name= "上证指数",
                    Close= "3299.70",
                    Change= "19.44",
                    ChangePercent= "0.59%",
                    Volume= "5.96亿",
                    Amount= "6772.55亿",
                    PreviousClose= "3280.26",
                    Open= "3280.76",
                    Hign= "3319.36",
                    Low= "3276.13"
                });
            }
            ZsItems = list;

            TabsItems = new ObservableCollection<HomeTabsItemModel>()
            {
                new HomeTabsItemModel (){  Title="涨停股池",Code="10",Content=new Ztgc()},
                new HomeTabsItemModel (){  Title="昨日涨停股池",Code="20",Content=new Ztgc()},
                new HomeTabsItemModel (){  Title="强势股池",Code="30",Content=new Ztgc()},
                new HomeTabsItemModel (){  Title="次新股池",Code="40",Content=new Ztgc()},
                new HomeTabsItemModel (){  Title="炸板股池",Code="50",Content=new Ztgc()},
                new HomeTabsItemModel (){  Title="跌停股池",Code="60",Content=new Ztgc()},
            };

            LhbItems = new ObservableCollection<HomeTabsModel>()
            {
                 new HomeTabsModel (){  Title="沪市",Code="10"},
                 new HomeTabsModel (){  Title="深市",Code="20"},
                 new HomeTabsModel (){  Title="科创",Code="30"}
            };
        }

        [RelayCommand]      
        private async Task ChangeItem(HomeTabsItemModel item)
        {
            //var addmodel = item as StockModel;
            //SelectedTabs = new TabItem { Header = addmodel.Title, Tag = addmodel.Code, Content = new TabCommon() };
            //TabsItem.Add(SelectedTabs);

            var result = await MessageBoxR.Confirm("是否改变数据？");
            Message.Show(result);
        }

        [RelayCommand]
        private async Task Delete(ZsDataModel info)
        {
            var result = await MessageBoxR.Confirm("是否删除信息？");
            Message.Show(result);
        }
       
    }
}
